<template>
  <div>
  <div>
    <button @click="foods.push({name:'西兰花',price:8})">添加西兰花</button>
  </div>
  <div v-for="(item,index) in foods" :key="index"><span>{{ index+1 }}--{{ item.name }}</span></div>
</div>
</template>

<script setup lang="ts">
import { ref } from "vue";
const foods=ref([
  {name:"苹果",price:5},
  {name:"香蕉",price:3},
  {name:"橘子",price:2}
])

</script>

<style>

</style>